<?php

namespace App\Traits;

/**
 * This file is part of Entrust,
 * a role & permission management solution for Laravel.
 *
 * @license MIT
 * @package Zizaco\Entrust
 */

use Zizaco\Entrust\Traits\EntrustUserTrait;

trait AdminUserTrait
{
    use EntrustUserTrait; //This will enable the relation with Role and add the following methods roles(), hasRole($name), withRole($name), can($permission), and ability($roles, $permissions, $options) within your User model.

    public function canRole($name, $requireAll = false)
    {
        if($this->hasRole('Administrator')){
            return true;
        }
        return $this->hasRole($name, $requireAll);
    }

    public function canPerm($permission, $requireAll = false)
    {
        if($this->hasRole('Administrator')){
            return true;
        }
        return $this->can($permission, $requireAll);
    }

    public function canAbility($roles, $permissions, $options = [])
    {
        if($this->hasRole('Administrator')){
            return true;
        }
        return $this->ability($roles, $permissions, $options);
    }

}
